package net.example.model.common;


import com.oraycn.omcs.utils.BufferUtils;
import com.oraycn.omcs.utils.SerializeUtils;

import io.netty.buffer.ByteBuf;

/**
 * Created by ZN on 2017/2/8.
 */

public class MessageFont{
    private String fontFamily;
    private int fontStyle;
    private float size = 9;

    public float getSize() {
        return size;
    }

    public void setSize(float size) {
        this.size = size;
    }

    public String getFontFamily() {
        return fontFamily;
    }

    public void setFontFamily(String fontFamily) {
        this.fontFamily = fontFamily;
    }

    public int getFontStyle() {
        return fontStyle;
    }

    public void setFontStyle(int fontStyle) {
        this.fontStyle = fontStyle;
    }

    public void deserialize(ByteBuf buffer) throws Exception {
        int len = buffer.readInt();
        if (len == -1) {
            return;
        }
        this.fontFamily = SerializeUtils.readStrIntLen(buffer);
        this.fontStyle = buffer.readInt();
        this.size = buffer.readFloat();
    }

    //手机端无需设置字体
    public byte[] serialize() {
        ByteBuf body = BufferUtils.newBuffer();
        int totalLen = -1;
        body.writeInt(totalLen);
        byte[] bytes = new byte[body.writerIndex()];
        body.getBytes(0, bytes);
        return bytes;
    }
}